<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/8/5
  Time: 15:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <script type="text/javascript" src="/js/jquery-3.4.1.js"></script>
    <script type="text/javascript">
        function register1(){
            var $mobile = $("#mobile").val();
            $.ajax({
                url:"MobileServlet",
                type:"post",
                data:"mobile=" + $mobile,
                success:function(result,testStatus){
                    if(result == "true"){
                        alert("此号码已存在！");
                    }else{
                        alert("此号码不存在！");
                    }
                },
                error:function(xhr,errorMessage,e){
                    alert("系统异常！");
                }
            })
        }

        function register2(){
            var $mobile = $("#mobile").val();
            $.get(
                "MobileServlet",
                "mobile="+$mobile,
                function(result){
                    if(result == "true"){
                        alert("此号码已存在！");
                    }else{
                        alert("此号码不存在！");
                    }
                },
                "text"
            )
        }

        function register3(){
            var $mobile = $("#mobile").val();
            $("#tip").load(
                "MobileServlet",
                "mobile="+$mobile
            )
        }

        function register4(){
            var $mobile = $("#mobile").val();
            $.getJSON(
                "MobileServlet",
                {"mobile":$mobile},
                function(result){
                    if(result.msg == "true"){
                        alert("此号码已存在！");
                    }else{
                        alert("此号码不存在！");
                    }
                }
            )
        }

    </script>
    <title>index</title>
  </head>
  <body>
      手机：<input id="mobile">
      <br/>
      <!--
      <input type="button" value="检测方式一" onclick="register1()"/>
      <input type="button" value="检测方式二" onclick="register2()"/>
      <input type="button" value="检测Load" onclick="register3()"/>-->
      <input type="button" value="检测getJSON" onclick="register4()"/><br/>
      <span id="tip"></span>
  </body>
</html>
